package com.freedy.dataStructure.graph;

/**
 * @author Freedy
 * @date 2021/4/4 14:01
 */
public class Test {
    public static void main(String[] args) {
        String[] vertexVal ={"1","2","3","4","5","6","7","8"};
        AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph(vertexVal.length);
        for (String s : vertexVal) {
            graph.insertVertex(s);
        }
        //添加边
        graph.insertEdge(0,1,1);
        graph.insertEdge(0,2,1);
        graph.insertEdge(1,3,1);
        graph.insertEdge(1,4,1);
        graph.insertEdge(3,7,1);
        graph.insertEdge(4,7,1);
        graph.insertEdge(2,5,1);
        graph.insertEdge(2,6,1);
        graph.insertEdge(5,6,1);
        graph.printGraph();
        graph.DFS();
        graph.BFS();
    }
}
